package com.dianrui.moonfire.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dianrui.moonfire.R;
import com.dianrui.moonfire.bean.OrderBean;

import java.util.List;

public class MyOrderBabyAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {

    private Context context;

    public MyOrderBabyAdapter(@Nullable List<OrderBean> data, Context context) {
        super(R.layout.order_list_item);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderBean item) {
        StringBuilder moneyBulider=new StringBuilder();
        moneyBulider.append("消费:").append("￥").append(item.money);

        StringBuilder carNumberBulider=new StringBuilder();
        carNumberBulider.append("车辆编号: ").append(item.number);

        helper.setText(R.id.time, item.start_time);
        helper.setText(R.id.start_path, item.start_path);
        helper.setText(R.id.end_path, item.end_path);
        helper.setText(R.id.number, carNumberBulider.toString());
        helper.setText(R.id.money, moneyBulider.toString());
        switch (item.status) {
            case "1":
                helper.setText(R.id.status,context.getResources().getString(R.string.going));
                helper.setTextColor(R.id.status,ContextCompat.getColor(context, R.color.blue_sky));
                break;

            case "2":
                helper.setText(R.id.status,context.getResources().getString(R.string.going));
                helper.setTextColor(R.id.status,ContextCompat.getColor(context, R.color.blue_sky));
                break;


            case "4":
                helper.setText(R.id.status,context.getResources().getString(R.string.finished));
                helper.setTextColor(R.id.status,ContextCompat.getColor(context, R.color.black));
                break;

            default:
                break;
        }


    }
}
